package com.bawei.nbluetoothdemo;

import android.Manifest;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.pm.PackageManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import androidx.core.app.ActivityCompat;

/**
 * @Author : 
 * @Time : On 2023/7/29 09:31
 * @Description : BaseAdapter
 */
public class MyAdapter extends BaseAdapter {
    private List<BluetoothDevice> mList;
    private Context mContext;

    public MyAdapter(List<BluetoothDevice> list, Context context) {
        mList = list;
        mContext = context;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("MissingPermission")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item, null);
        TextView textView = convertView.findViewById(R.id.tv);
        textView.setText(mList.get(position).getName()+"");
        return convertView;
    }
}
